Skip to content

Add Lua rockspec package handler for LuaRocks dependencies#4743

Open
SLASH217 wants to merge 9 commits intoaboutcode-org:developfrom
SLASH217:support_rockspec
Open

Add Lua rockspec package handler for LuaRocks dependencies#4743
SLASH217 wants to merge 9 commits intoaboutcode-org:developfrom
SLASH217:support_rockspec

Conversation

@SLASH217
Copy link

@SLASH217 SLASH217 commented Feb 13, 2026

Add Lua rockspec package handler for LuaRocks dependencies

Fixes #3526

Changes

  • Added RockspecHandler class for .rockspec file detection
  • Implemented RockspecParser using Lua AST parsing with luaparser library
  • Extracts package metadata: name, version, description, license, homepage_url, vcs_url (non-exhaustive list)
  • Integrated handler into APPLICATION_PACKAGE_DATAFILE_HANDLERS registry
  • Added 23 comprehensive unit and integration tests
  • Fixed dead documentation links in CONTRIBUTING.rst

Tasks

  • Reviewed contribution guidelines
  • PR is descriptively titled 📑 and links the original issue above 🔗
  • Tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR
    Run tests locally to check for errors.
  • Commits are in uniquely-named feature branch and has no merge conflicts 📁
  • Updated documentation pages (if applicable)
  • Updated CHANGELOG.rst (if applicable)

Signed-off-by: Prashanna Dahal prashanna217@gmail.com

Prashanna Dahal added 5 commits February 13, 2026 14:04
Implement base handler class and Lua rockspec parser
using luaparser for AST-based dependency extraction.

Signed-off-by: Prashanna Dahal <prashanna217@gmail.com>
Extract package metadata and dependencies from
rockspec files with version specification parsing.

Signed-off-by: Prashanna Dahal <prashanna217@gmail.com>
* Test parser with real Kong rockspec file
* Test handler integration with patterns

Signed-off-by: Prashanna Dahal <prashanna217@gmail.com>
Register handler in APPLICATION_PACKAGE_DATAFILE_HANDLERS
to enable automatic .rockspec file detection.

Signed-off-by: Prashanna Dahal <prashanna217@gmail.com>
* Update contributing-docs link to new structure
* Ensure both documentation links work correctly
* Point to getting-started/contribute path

Signed-off-by: Prashanna Dahal <prashanna217@gmail.com>
Change luaparser from == to match project's version pinning pattern:
* requirements.txt: luaparser==1.4.3 (exact pinning)
* setup.cfg: luaparser == 1.4.3 (exact pinning)

Signed-off-by: Prashanna Dahal <prashanna217@gmail.com>
Prashanna Dahal added 3 commits February 14, 2026 17:47
Signed-off-by: Prashanna Dahal <prashanna217@gmail.com>
- This was causing a test to fail in CI/CD
Signed-off-by: Prashanna Dahal <prashanna217@gmail.com>
- Extra "/n" causing failure of CI/CD
Signed-off-by: Prashanna Dahal <prashanna217@gmail.com>
Copy link
Member

@AyanSinhaMahapatra AyanSinhaMahapatra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks++ @SLASH217 for the PR, looking good already, but you need to modify the tests so we can see the full output and verify the functionality added before I can do an in depth review. Added some other feedback you also need to address.

parser = rockspec.RockspecParser(test_file)
data = parser.parse()

assert data['rockspec_format'] == '3.0'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not how we write tests for package manifest parsers, asserting the data one by one. Instead we dump the whole results in a JSON file and check the output matches to it, so we can see the entire output and test it, and not just some fields. And this result is more readable, and for changes we can regen and check the changes in output.
This is done using tests.packagedcode.packages_test_utils.Packagetester.check_packages_data()

See how this is done in all other test files for package manifest parsers, for example:

self.check_packages_data(package, expected_loc, regen=REGEN_TEST_FIXTURES)

build = {
type = "builtin",
modules = {
["kong"] = "kong/init.lua",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK we are not parsing/storing the modules info here and this is increasing the test file size without contributing anything to the test, can you remove these modules from all the tests?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for all non essential things in other test files.

@@ -0,0 +1,530 @@
package = "kong"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be great to add the link to this test file (and all others) as a comment, since these are real files(?) and we should provide where we got them from

- name: Package name
- version_number: Clean version number (e.g. "3.1.3") or None
- version_spec: Full version specification with operator (e.g. "== 3.1.3") or None
- raw: Original input string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why you want to pass back the input, don't we already have this in context?

package_name: Name of the package
package_version: Optional version string (without operators)

Returns:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is additional information you're conveying twice, and not how we write the docstrings. Just describe the output, what it does and the inputs in a short to-the-point docstring. For all the functions

extra_data['supported_platforms'] = platforms

# Future fields can be added here
# e.g., build_backend, build_requires, etc.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just add these now? And if you're keeping work for later, add a TODO:

jsonstreams >= 0.5.0
license_expression >= 30.4.4
lxml >= 5.4.0
luaparser == 4.0.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not pin dependencies, you can add this as a lower bound. We are a library too :)

keyring==23.7.0
license-expression==30.4.4
lxml==6.0.2
luaparser==4.0.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also installing two new dependencies, can you also add these here?
https://github.com/boolangery/py-lua-parser/blob/master/setup.py#L29


git checkout -b name-of-your-bugfix-or-feature

4. Check out the Contributing to Code Development `documentation <https://scancode-toolkit.readthedocs.io/en/stable/contribute/contrib_dev.html>`_, as it contains more in-depth guide for contributing code and documentation.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching and fixing this!

@AyanSinhaMahapatra AyanSinhaMahapatra added the need-changes PR needs to be updated with feedback label Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

need-changes PR needs to be updated with feedback

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for luarocks spec

2 participants

Comments